package com.springcontext.ioc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * 在每个bean实例化 前后执行
 */
//@Component
public class BeanPostProcessorDemo implements BeanPostProcessor {

  Logger LOGGER = LoggerFactory.getLogger(this.getClass());

  @Override
  public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    LOGGER.warn("postProcessAfterInitialization " + beanName);
    return bean;
  }

  @Override
  public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
    LOGGER.warn("postProcessBeforeInitialization " + beanName);
    return bean;
  }

}
